<template>
    <div class="login_container">
        <div class="login_box">
            <!-- 头像 -->
            <div class="avatar_box">
                <img src="../../assets/imgs/avater.png" alt=""> 
            </div>
            <!-- 登录的表单组件 -->
            <div>
                 <el-form :model="loginForm" :rules="loginRules" ref="loginForm" label-width="0px" class="login_form">
            <el-form-item prop="username">
                <el-input v-model="loginForm.username" placeholder="请输入用户名称" prefix-icon="el-icon-user-solid"></el-input>
            </el-form-item>
            <el-form-item prop="password">
                <el-input v-model="loginForm.password" placeholder="请输入登录密码" prefix-icon="el-icon-lock"></el-input>
            </el-form-item>
            <el-form-item prop="verifyCode">
            <div class="verifyCode_box">
                <el-input v-model="loginForm.verifyCode" placeholder="请输入手机验证码" prefix-icon="el-icon-mobile" class="verifyCode"></el-input>
                <img src="../../assets/imgs/yzm.png" alt="" class="verifyCode_img">
            </div>
            </el-form-item>
            <el-form-item class="login_btn">
                <el-button type="primary" @click="submitForm('loginForm')">登 录</el-button>
                <el-button @click="resetForm('loginForm')">重置</el-button>
            </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                loginForm: {
                    username:"liushidi",
                    password:"12345"
                },
               
            }
        },
        methods: {
             submitForm(formName) {
                    this.$refs[formName].validate((valid) => {
                    if (valid) {
                         this.$router.push("/home");
                    } else {
                        console.log('error submit!!');
                    return false;
                    }
                });
            },
        },
    }
</script>

<style lang="less" scoped>
    .login_container {
    height: 100%;
    background-color: aquamarine;
    display: flex;
    align-items: center;
    justify-content: center;

    .login_box{
        width: 450px;
        height: 320px;
        background-color: #fff;
        border-radius: 3px; 
        padding:100px 20px 0px 20px;
        position: relative;

    .avatar_box{
        width: 100px;
        height: 100px;
        position: absolute;
        left: 165px;
        top: -85px;
        border: 1px solid #ccc;
        padding: 10px;
        border-radius: 60px;
        background-color: #fff;

        img{
            width: 100%;
            height: 100%;
            border-radius: 50%;
           
        }  
    }

     .verifyCode_box {
      display: flex;

      .verifyCode {
        flex: 2;
      }

      image {
        flex: 1;
      }
    }

    }

    
  }
    
</style>